<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="bounced.js"></script>
  <script src="throttle.js"></script>
</head>

<body>
  <script>
    
    var resCount = 0
    var mmFunc = debounce((e) => {
      resCount += 1
      console.log('mousemove Event debounce', resCount)
      return resCount
    }, 1000, {
      leading: true, // true表示第一次一定会先运行函数
      maxWait: 3000, // 不管怎么样，每隔maxWait一定会运行一次函数
      // trailing: false // true表示最后不再运行函数，false只返回上一次的结果
    })
    // document.addEventListener('mousemove', mmFunc)
    var nnFunc = throttle((e) => {
      resCount += 1
      console.log('mousemove Event throttle', resCount)
    }, 2000, {
      leading: false,
      trailing: false,
    })
    document.addEventListener('mousemove', nnFunc)
  </script>
</body>

</html>